package lumis.content.search.common;

import java.util.Collection;

import lumis.content.core.Content;
import lumis.doui.search.common.DouiIndexConfig;
import lumis.portal.PortalException;

/**
 * Provides operations on content search indexing.
 *
 * @version $Revision: 10458 $ $Date: 2009-06-02 15:49:09 -0300 (Tue, 02 Jun 2009) $
 * @since 4.2.0
 */
public interface IContentIndexer
{
	/**
	 * Name of the field used to store the content's identifier in the search
	 * index.
	 * @since 4.2.0
	 */
	public static final String FIELDNAME_CONTENT_ID = "lum_contentId";
	
	/**
	 * Name of the field used to store the content version's last modified
	 * date time. The value of this field is set with the number of milliseconds 
	 * since January 1, 1970, 00:00:00 GMT.
	 * @since 4.2.2
	 */
	public static final String FIELDNAME_LAST_MODIFIED_DATE_TIME = "lum_lastModifiedDateTime";
	
	/**
	 * The attribute name used to store the service instance identifiers
	 * in the transaction, for use when removing the content from the index.
	 * @since 4.2.0
	 */
	public static final String SERVICE_INSTANCE_IDS_ATTRIBUTE_NAME = "lumis.content.search.common.IContentIndexer#SERVICE_INSTANCE_IDS";

	/**
	 * Creates a default index configuration for the given content. 
	 * @param content the content.
	 * @return the index configuration.
	 * @since 4.2.0
	 */
	public DouiIndexConfig createDouiIndexConfig(Content content) throws PortalException;
	
	/**
	 * Removes the given content from the search index.
	 * @param content the content.
	 * @param serviceInstanceIds the identifiers of the service instances
	 * whose indices the content will be removed from.
	 * @param douiIndexConfig indexing configuration.
	 * @since 4.2.0
	 */
	public void removeContentFromIndex(Content content, Collection<String> serviceInstanceIds,
			DouiIndexConfig douiIndexConfig) throws PortalException;
	
	/**
	 * Performs the re-indexing of the given content.
	 * @param content the content.
	 * @param serviceInstanceIds the identifiers of the service instances
	 * whose indices the content will be removed from.
	 * @param douiIndexConfig indexing configuration.
	 * @since 4.2.0
	 */
	public void reindexContent(Content content, Collection<String> serviceInstanceIds,
			DouiIndexConfig douiIndexConfig) throws PortalException;
}
